<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>

    <script src="js/jquery-3.3.1.min.js"></script>

    <script src="js/jquery.md5.js"></script>
    <!-- Bootstrap -->
    <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

</head>

<script>

    $(function () {
        $("#login_btn").click(function () {
           if($("#inputId").val() == null || $("#inputId").val() === "" || $("#inputPassword").val() == null || $("#inputPassword").val() == ""){
               alert("信息不能为空！");
           }else{
               //alert($('input:radio[name="optionsRadios"]:checked').val());
               var psw = $("#inputPassword").val();
               psw = $.md5(psw);
               $("#inputPassword").val(psw);
               if($('input:radio[name="optionsRadios"]:checked').val() === "employee"){
                   $.post("/report/login/employeeLogin",
                       {id: $("#inputId").val(),
                        password: $("#inputPassword").val()},
                        function (msg) {
                            if(msg === "success"){
                                //alert(msg);
                                window.location.href = "/report/page/employee.html";
                            }else{
                                alert("密码错误");
                            }
                        });
               }else{
                   $.post("/report/login/managerLogin",
                       {id: $("#inputId").val(),
                           password: $("#inputPassword").val()},
                       function (msg) {
                           if(msg === "success"){
                               window.location.href = "/report/page/manager.html";
                           }else{
                               alert("密码错误");
                           }
                       });
               }
           }

        });
    });

</script>

<body style="background-color: #f7f7f7">
    <div id="left_div" style="width: 20%; float: left">
        <br/>
    </div>
    <div id="center_div" style="width: 60%; height: auto; margin-top: 200px; float: left; padding: 20px; border: groove;">
        <div id="show_div" style="width: 45%; height: 100%; float: left; background-color: #1b6d85">
            <img src="img/face.jpg" alt="" class="img-rounded" style="max-width: 100%">
        </div>
        <div id="login_div" style="width: 50%; height: 100%; float: right; margin-left: 5%; margin-top: 10px">
            <form class="form-horizontal">
                <div class="form-group">
                    <label for="inputId" class="col-md-3 control-label">工号/学号</label>
                    <div class="col-md-7">
                        <input type="text" class="form-control" id="inputId" placeholder="工号/学号">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputPassword" class="col-md-3 control-label">密码</label>
                    <div class="col-md-7">
                        <input type="password" class="form-control" id="inputPassword" placeholder="密码">
                    </div>
                </div>
                <div class="row">
                    <label for="box" class="col-md-3 control-label">身份</label>
                    <div id="box" class="col-md-7">
                        <div class="radio">
                            <label>
                                <input type="radio" name="optionsRadios" id="optionsRadios1" value="manager" checked>
                                管理员
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="optionsRadios" id="optionsRadios2" value="employee" checked>
                                员工
                            </label>
                        </div>
                    </div>
                </div>
            </form>
            <div class="row" style="margin-top: 20px">
                <div class="col-md-3"></div>
                <button id="login_btn" class="btn btn-lg btn-primary">登录</button>
            </div>
            <span style="color: red; font-size: 12px; float: right; margin-right: 30px">忘记密码请联系管理员找回</span>
        </div>
    </div>
    <div id="right_div" style="width: 20%; float:right;">
        <br/>
    </div>
</body>
</html>